﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace yq.IBase.DBHelper.Paging
{
    internal class MysqlPager : IPager
    {
        public System.Data.DataTable Paging(string sql, string orderby, int currentPageIndex, int pageSize, DbHelper hp)
        {
            sql = sql + orderby;
            sql = sql + " Limit " + ((currentPageIndex - 1) * pageSize) + "," + pageSize + " ";


            return hp.ExecuteDataTable(hp.GetSqlStringCommond(sql));
        }

        public int CountPaging(string sql, DbHelper hp)
        {
            sql = "SELECT count(1) from ( " + sql + ") as yq";
            object obj = hp.ExecuteScalar(hp.GetSqlStringCommond(sql));

            return Convert.ToInt32(obj);
        }


    }
}
